Sequential vs. Parallel Choices are Everywhere

Mark Leighton Fisher on 2007-06-01T16:58:47

grep(1)'s usage is inherently parallel – you retrieve a bunch of matches at once (all of the matches if your display device can handle it). GUI editor search is often sequential – you must examine each match in turn. If you want to modify each matched piece in turn, then a GUI search is good enough. If you want to know whether you have 4 or 140 places to modify before starting your modifications, then GUI search is the wrong approach.

vi(1) and Vim get this dichotomy right, as you can search either sequentially or in parallel (this is probably due to their heritage as descendants of ed(1)). GUI editors of whatever stripe, as implemented today, seem focused on manipulating what you can see one piece at a one time. Graphical editors support zoom features, but you lose detail when you try to work on large sections of the dataset/document/whatever.

Sometimes you want to operate sequentially, but other times you want to operate in parallel. Although you would think that GUI interfaces would be the interface of choice for parallel operations, it seems ofttimes that command-line interfaces support parallel operations better. (Maybe that's part of why Microsoft developed PowerShell.) A command-line interface forces you to step back and think about what you want to do, rather than directly operating on each item in order. That may be the difference – with a GUI interface, you can operate easily on individual items, so that is how programmers develop their software, with the focus on operating on individual items. Meanwhile, command-line interface programmers are forced to step away from direct data manipulation due to the limitations of the command-line interface, so greater concentration is placed on operations for groups of data.

Perl has good support for operating in parallel, as map() and grep() (spelled filter in functional) let you operate on all your data in parallel if you so choose. Mark Jason Dominus's Higher-Order Perl and his Memoize module (among the other functional-style CPAN modules) show how easy it is to extend Perl for all sorts of parallel operations. LINQ looks like an interesting .NET technology, although you can do everything LINQ can do (I think) with map() and grep() in Perl.